#ifndef DBUSARGVMODEL_HPP
#define DBUSARGVMODEL_HPP

#include <QObject>
#include <qabstractitemmodel.h>

#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVariant>
#include "common.hpp"
class DBusArgvItem;
class DBusArgvModel : public QAbstractItemModel
{
    Q_OBJECT
public:
    DBusArgvModel(const QStringList &names, const QList<int> &args,QObject *parent = 0);
    DBusArgvModel(const QStringList &names, const QStringList &args,QObject *parent = 0);
    DBusArgvModel(const QStringList &names, const QList<DVariant> values,QObject *parent = 0);
    ~DBusArgvModel();
    QList<DVariant> getArgs(bool *ok);
    QVariant data(const QModelIndex &index, int role) const override;
    bool setData(const QModelIndex &index, const QVariant &value, int role) override;
    QVariant headerData(int section, Qt::Orientation orientation,
                        int role = Qt::DisplayRole) const override;

    QModelIndex index(int row, int column,
                      const QModelIndex &parent = QModelIndex()) const override;
    QModelIndex parent(const QModelIndex &index) const override;

    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;
    Qt::ItemFlags flags(const QModelIndex &index) const override;
    bool removeColumns(int position, int columns,
                       const QModelIndex &parent = QModelIndex()) override;
    bool insertRows(int position, int rows,
                    const QModelIndex &parent = QModelIndex()) override;
    bool removeRows(int position, int rows,
                    const QModelIndex &parent = QModelIndex()) override;
    bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
signals:
    void commitModelData(QAbstractItemModel *model, const QModelIndex &index) const;
public:
    DBusArgvItem *getItem(const QModelIndex &index) const;
public slots:
//    void commitModelData(QAbstractItemModel *model, const QModelIndex &index) const;
private:
    void setupModelData(const QStringList &lines, DBusArgvItem *parent);


    DBusArgvItem *rootItem;

};




#endif // DBUSARGVMODEL_HPP
